import config
import pytest
from common.common import assert_success
from api.loginAPI import Loginapi
from api.dept import Deptapi
#定义业务流程类
class TestBusinessProcess:
    token666 = None
    id666=None
    def setup_class(self):
        self.login_api = Loginapi()
        self.dept_api = Deptapi()
        login_data = {
            "mobile": "13800000002",
            "password": "123456"
        }
        response = self.login_api.login(login_data)
        TestBusinessProcess.token666 = response.json().get("data")
        assert_success(response)
    def test01_get_dept_list(self):
        response = self.dept_api.get_dept_list(TestBusinessProcess.token666)
        print(response.json())
        assert_success(response)
    def test02_insert_dept(self):
        json_data={
            "name":"孙乐",
            "code":"1233212220"
        }
        response = self.dept_api.insert_dept(TestBusinessProcess.token666,json_data)
        assert_success(response)
        TestBusinessProcess.id666=response.json().get("data").get("id")
        print(TestBusinessProcess.id666)
    def test03_select_dept(self):
        response = self.dept_api.select_dept(TestBusinessProcess.token666,TestBusinessProcess.id666)
        assert_success(response)
    def test04_update_dept(self):
        json_data2={
            "name": "孙乐乐"
        }
        response = self.dept_api.update_dept(TestBusinessProcess.token666,TestBusinessProcess.id666,json_data2)
        assert_success(response)
    def test05_delect_dept(self):
        response = self.dept_api.delect_dept(TestBusinessProcess.token666,TestBusinessProcess.id666)
        assert_success(response)
